package runner;

import java.util.ArrayList;

import Operators.DrumOperator;
import Route.*;
import States.StationState;
import Templates.Operator;
import Templates.State;
import Algorithms.Algoritm;
import Algorithms.BeamSearch;
import Algorithms.DepthLimitedSearch;
import Algorithms.DepthSearch;
import Algorithms.Dijkstra;
import Algorithms.IterativeDeepingSearch;
import Algorithms.SimulatedAnnealingSearch;
import Algorithms.WidthSearch;

public class DateBD {

	/**
	 * @param args
	 */
	
	public static ContainerLegaturi cl;
    private static String StationDepthLimited;
    private static String StationIterativeDeeping;
    private static String StationBeam;
    private static String StationSimulatedAnnealing;
	
	public static void main(String[] args) {

		// TO-DO
		// citire statii si legaturi din BAZA DE DATE si populate cele doua container-e de mai jos

		ContainerStatii cs = new ContainerStatii(new Statie(0, "Zero", 123, 123), new Statie(1, "Unu", 234,
				234), new Statie(2, "Doi", 124, 231), new Statie(3, "Trei", 614, 214));

		cl = new ContainerLegaturi(new Legatura(cs.getStatie(0), cs.getStatie(1), 7),
				new Legatura(cs.getStatie(0), cs.getStatie(2), 9), new Legatura(cs.getStatie(0), cs
						.getStatie(3), 14), new Legatura(cs.getStatie(1), cs.getStatie(2), 10), new Legatura(
						cs.getStatie(1), cs.getStatie(3), 15), new Legatura(cs.getStatie(2), cs.getStatie(3),
						11), new Legatura(cs.getStatie(2), cs.getStatie(0), 21));

		// TO-DO
		// citire tip algoritm si statie pornire respectiv destinatie din INTERFATA
		// afisare rezultate

		Algoritm d = new Dijkstra();

		Statie[] l = d.executa(cs.toVector(), cl.toVector(), cs.getStatie(2), cs.getStatie(0));

		for (Statie s : l) {
			System.out.println(s.getCod() + " " + s.getNume());
		}

		StationState ex = new StationState(cs.getStatie(0));
		/**  Station States Initialize**/
		ArrayList<Operator<Statie>> drumOperators=DrumOperator.returnOperators();
		State<Statie> stationInitialState=ex.initalState();
		StationState.curenta = cs.getStatie(2);
		ArrayList<State<Statie>> stationFinalState=ex.finalStates();
		StationState.curenta = cs.getStatie(0);
		/** Station End **/
		
		String StationDepth="StationDepth.txt";
		String StationWidth="StationWidth.txt";
		
		 /** Station Execution **/
		DepthSearch<Statie> stationDepth=new DepthSearch<Statie>(stationInitialState,stationFinalState,drumOperators,StationDepth);
		WidthSearch<Statie> stationWidth=new WidthSearch<Statie>(stationInitialState,stationFinalState,drumOperators,StationWidth);
		stationDepth.executeAlgorithm();
                stationWidth.executeAlgorithm();
                
		DepthLimitedSearch<Statie> stationDepthLimited=new DepthLimitedSearch<Statie>(stationInitialState,stationFinalState,null,StationDepthLimited);
		IterativeDeepingSearch<Statie> stationIterativeDeeping=new IterativeDeepingSearch<Statie>(stationInitialState,stationFinalState,null,StationIterativeDeeping);
		
		BeamSearch<Statie> stationBeam=new BeamSearch<Statie>(stationInitialState,stationFinalState,null,StationBeam);
		SimulatedAnnealingSearch<Statie> stationSimulatedAnnealing=new SimulatedAnnealingSearch<Statie>(stationInitialState,stationFinalState,null,StationSimulatedAnnealing);
		
		stationDepthLimited.executeAlgorithm();
		stationIterativeDeeping.executeAlgorithm();
		stationBeam.executeAlgorithm();
		stationSimulatedAnnealing.executeAlgorithm();
                
	    /** Station Execution End **/
	}
}
